import http from '@/service/http'
import * as T from './types'

export const knowledgeBaseApi: T.IKnowledgeBaserApi = {
  getKnowledgeBaseList() {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/list-knowledge-bases'
    )
  },
  getKBFilesList(params) {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/list-files',
      params
    )
  },
  createKB: function (params): Promise<void> {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/create-knowledge-base',
      params
    )
  },
  updateKBInfo: function (params): Promise<void> {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/update-knowledge-info',
      params
    )
  },
  deleteKB: function (params): Promise<void> {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/del-knowledge-base',
      params
    )
  },
  deleteFile: function (params): Promise<void> {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/delete-docs',
      params
    )
  },
  uploadKBFile(params, onUploadProgress, signal) {
    return http.upload(
      '/langchainServer/api/langchain/knowledge_base/v1/upload-docs',
      params,
      onUploadProgress,
      signal
    )
  },
  updateFiles(params) {
    return http.post(
      '/langchainServer/api/langchain/knowledge_base/v1/update-docs',
      params
    )
  }
}
